import requests


def generate_plot(prompt, ollama_api_key):
    headers = {"Authorization": f"Bearer {ollama_api_key}"}
    payload = {"prompt": prompt}
    response = requests.post("https://api.ollama.com/generate_plot", headers=headers, json=payload)

    if response.status_code == 200:
        plot_data = response.json()
        return plot_data['plot']
    else:
        print(f"Plot generation failed: {response.status_code}")
        return None


# # 使用示例
# generated_plot = generate_plot("科幻背景下的人工智能起义", "your_ollama_api_key_here")
# if generated_plot:
#     print(generated_plot)